<script>
//JavaScript代码区域
layui.use('element', function(){
  var element = layui.element;
});
layui.use('layer', function(){ 
  var $ = layui.jquery, layer = layui.layer; 
  var active = {
    admin_set: function(){
      var that = this; 
      var url = $(this).attr('url');
      layer.open({
        type: 2 
        ,title: '115CMS.COM'
        ,area: ['100%', '100%']
        ,shade: 0
        ,maxmin: true
        ,content: url
        ,btn: ['关闭'] 
        ,btn2: function(){
          layer.closeAll();
        }
        ,zIndex: layer.zIndex 
        ,success: function(layero){
          layer.setTop(layero); 
        }
      });
    }
  };
  $('#admin_set .layui-btn').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
});
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  //更新
  form.on('switch(index)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
     var url= jq(this).attr('url');
    var param = data.field;
    jq.post(url,param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 6, time: 1000}, function(){
         //location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //删除
  form.on('submit(delete)', function(data){
    var param = data.field;
    var name = jq(this).attr('member-name');
    var url= jq(this).attr('url');
    //弹出提示
    layer.confirm(''+name+'', function(index){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    jq.post(url,param,function(data){
	
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
         location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  });
});
</script>
</body>
</html>